home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-06 | 1.4 KB | 42 lines | [TEXT/GEOL] |
- Item 9856462 4-April-90 00:39PDT
-
- From: D0532 Aidea Systems, Don Park,PRT
-
- To: CPLUS.DEV$ C++ Interest List--Developers
- CPLUS.APPLE$ C++ Interest List--Apple Employees
-
- Sub: Who's on first?
-
- Does anyone know what the order of static object instantiation is?
-
- Here is the situation:
-
- in file A.cp:
-
- static class AClass { ... } A;
-
- in file B.cp:
-
- static class BClass { ... } B;
-
- Now suppose BClass constructor calls AClass. It would be a disaster if A is
- not instantiated before B. I understand that the situation would be clear if
- both static objects were in one file, but how does one specify the order of
- instantiation among static objects scattered across files?
-
- If the linker figures this out by noting that B uses A so A has to be
- instantiated first, then is that the standard or specific to MPW?
-
- If the order of linking determines the order of instantiation, then it seem a
- bit limiting since file A.cp and B.cp could have another pair of static objects
- with reverse relationship.
-
- If there is no guarantee of order, then I will have to require static objects
- that access other static objects to delay access until one can be sure that all
- static objects have been instantiated. This is clearly a hack.
-
- So, who is on first?
-
- Don Park
-
-